package com.jiong.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class DBUtil {

    public DBUtil() {

        try {
            Class.forName("com.mysql.jdbc.Driver");
        }
        catch (ClassNotFoundException e) {
            e.printStackTrace();
        }

        String url = "jdbc:mysql://localhost:3306/jfinal_demo?useUnicode=true&characterEncoding=utf8";
        String user = "root";
        String password = "";
        Connection connection = null;

        try {
            connection = DriverManager.getConnection(url, user, password);
        }
        catch (SQLException e) {
            System.out.println("数据库连接失败！");
            e.printStackTrace();
        }

        System.out.println(connection);
    }

    public static void main(String[] args) {

        new DBUtil();
    }
}
